<?php
	//include_once('verifica.php');
	include_once('config/class.pdo.php');
	
	//print_r($_POST[id]);
	if(isset($_POST['id'])) {
		$pdo = new DB;	
		$pdo-> conexao();
		
		$Query = 'SELECT 
					nome,
					advogado,
					cpf,
					rg,
					orgaoExpeditor,
					estadoCivil,
					CTPS,
					serieCTPS,
					PIS,
					date_format(dataNascimento, "%d/%m/%Y") as dataNascimento,
					celular,
					email,
					nomeMae,
					nomePai,
					nomeConjuge,
					OAB,
					date_format(dataCadastro, "%d/%m/%Y %T") as dataCadastro,
					idEntidade
				  FROM entidade 
		WHERE idEntidade = '.$_POST['id'].'';
		$result = $pdo->oneReg($Query);				
		//print_r($result);
	} 			
?>
<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<link rel="stylesheet" href="css/jquery-ui.css" />
		<link rel="stylesheet" href="css/style.css" />
		<script type="text/javascript" src="js/jquery-1.9.1.js" ></script>
		<script type="text/javascript" src="js/jquery-ui.js" ></script>	
		<script type="text/javascript" src="js/jquery.maskedinput.js" ></script>		
		<script type="text/javascript" src="js/jquery.validate.js" ></script>
		<script type="text/javascript" src="js/jsCadAdvogado.js"></script>	
		<script type="text/javascript" src="js/funcoes.js"></script>			
	</head>	
	<body style="font-size:10px;">
		<form name="frmAdvogado" id="frmAdvogado" method="POST">
			<div id="divAdvogado" class="divAdvogado">
				<fieldset class="backFieldset">
					<legend> <b> Cadastro de Advogado </b> </legend>
					<table class="table">
						<?php 
							if(isset($_POST['id'])) {
								echo '<tr>';
								echo '<td> Código: </td>';
								echo '<td colspan=0> <input type="text" name="ca_id" id="ca_id" value="'.$result['idEntidade'].'" readonly /> </td>';
								echo '<td> Cadastro: </td>';
								echo '<td colspan=0> <input type="text" name="ca_dataCadastro" id="ca_dataCadastro" value="'.$result['dataCadastro'].'" readonly /> </td>';
								echo '</tr>';
							}
						?>
						<tr> 
							<td> Nome: </td>
							<td colspan=3> <input type="text" name="ca_nome" id="ca_nome" class="input-xxlarge" title="Campo NOME deve ser preenchido." value="<?php echo utf8_encode(@$result['nome']); ?>" required /> </td>
						</tr>
						<tr>
							<td> OAB: </td>
							<td colspan=0> <input type="text" name="ca_oab" id="ca_oab" title="Campo OAB deve ser preenchido." value="<?php echo @$result['OAB']; ?>" required size="100" /> </td>
							<td> CPF: </td>
							<td colspan=0> <input type="text" name="ca_cpf" id="ca_cpf" onBlur="valida(ca_cpf);" maxlength="14" title="Campo CPF deve ser preenchido." value="<?php echo @$result['cpf']; ?>" required size="100" /> </td>
						</tr>
						<tr>
							<td> RG: </td>
							<td colspan=0> <input type="text" name="ca_rg" id="ca_rg" title="Campo RG deve ser preenchido." value="<?php echo @$result['RG']; ?>" size="13" /> </td>
							<td> Orgão Expeditor </td>
							<td colspan=0> <input type="text" name="ca_orgaoExpeditor" id="ca_orgaoExpeditor" title="Campo ORGÃO EXPEDITOR deve ser preenchido." value="<?php echo @$result['orgaoExpeditor']; ?>" size="13" /> </td>
						</tr>	
						<tr>
							<td> Estado Civil: </td>
							<td colspan=0> 
								<select name="ca_estadoCivil" id="ca_estadoCivil">
								<?php
									if (@$result['estadoCivil'] == '1'){
										echo '<option value=""> -- SELECIONE -- </option>';
										echo '<option value="1" selected> Casado(a) </option>';
										echo '<option value="2"> Solteiro(a) </option>';
										echo '<option value="3"> Divorciado(a) </option>';
										echo '<option value="4"> Viúvo(a) </option>';
									} else if (@$result['estadoCivil'] == '2'){
										echo '<option value=""> -- SELECIONE -- </option>';
										echo '<option value="1"> Casado(a) </option>';
										echo '<option value="2" selected> Solteiro(a) </option>';
										echo '<option value="3"> Divorciado(a) </option>';
										echo '<option value="4"> Viúvo(a) </option>';
									} else if (@$result['estadoCivil'] == '3'){
										echo '<option value=""> -- SELECIONE -- </option>';
										echo '<option value="1"> Casado(a) </option>';
										echo '<option value="2"> Solteiro(a) </option>';
										echo '<option value="3" selected> Divorciado(a) </option>';
										echo '<option value="4"> Viúvo(a) </option>';
									} else if (@$result['estadoCivil'] == '4'){
										echo '<option value=""> -- SELECIONE -- </option>';
										echo '<option value="1"> Casado(a) </option>';
										echo '<option value="2"> Solteiro(a) </option>';
										echo '<option value="3"> Divorciado(a) </option>';
										echo '<option value="4" selected> Viúvo(a) </option>';
									} else {
										echo '<option value=""> -- SELECIONE -- </option>';
										echo '<option value="1"> Casado(a) </option>';
										echo '<option value="2"> Solteiro(a) </option>';
										echo '<option value="3"> Divorciado(a) </option>';
										echo '<option value="4"> Viúvo(a) </option>';
									}
								?>
								</select>							
							</td>
							<td> Nascimento: </td>
							<td colspan=0> <input type="text" name="ca_dataNascimento" id="ca_dataNascimento" title="Campo DATA DE NASCIMENTO deve ser preenchido." onBlur="VerificaData(this.value);" value="<?php echo @$result['dataNascimento']; ?>" size="13" /> </td>
						</tr>	
						<tr>
							<td> CTPS: </td>
							<td colspan=0> <input type="text" name="ca_ctps" id="ca_ctps" title="Campo CTPS deve ser preenchido." value="<?php echo @$result['CTPS']; ?>" size="13" /> </td>
							<td> Série CTPS: </td>
							<td colspan=0> <input type="text" name="ca_serieCtps" id="ca_serieCtps" title="Campo SÉRIE CTPS deve ser preenchido." value="<?php echo @$result['serieCTPS']; ?>" size="13" /> </td>
						</tr>
						<tr>
							<td> PIS: </td>
							<td colspan=0> <input type="text" name="ca_pis" id="ca_pis" title="Campo PIS deve ser preenchido." value="<?php echo @$result['PIS']; ?>" size="13" /> </td>
						</tr>
						<tr>
							<td> Celular: </td>
							<td colspan=0> <input type="text" name="ca_celular" id="ca_celular" title="Campo CELULAR deve ser preenchido." value="<?php echo @$result['celular']; ?>" size="13" /> </td>
							<td> E-Mail: </td>
							<td colspan=0> <input type="email" name="ca_email" id="ca_email" title="E-MAIL deve ser preenchido corretamente." value="<?php echo @$result['email']; ?>" size="13" /> </td>
						</tr>
						<tr>
							<td> Nome Mãe: </td>
							<td colspan=3> <input type="text" name="ca_nomeMae" id="ca_nomeMae" class="input-xxlarge" title="Campo NOME MÃE deve ser preenchido." value="<?php echo utf8_encode(@$result['nomeMae']); ?>" size="13" /> </td>
						</tr>
						<tr>
							<td> Nome Pai: </td>
							<td colspan=3> <input type="text" name="ca_nomePai" id="ca_nomePai" class="input-xxlarge" title="Campo NOME PAI deve ser preenchido." value="<?php echo utf8_encode(@$result['nomePai']); ?>" size="13" /> </td>
						</tr>
						<tr>
							<td> Nome Conjuge: </td>
							<td colspan=3> <input type="text" name="ca_nomeConjuge" id="ca_nomeConjuge" class="input-xxlarge" title="Campo NOME CONJUGE deve ser preenchido." value="<?php echo utf8_encode(@$result['nomeConjuge']); ?>" size="13" /> </td>
						</tr>
						<tr>
						<?php
							if(isset($_POST['id'])) {
								echo '<td colspan=4 align="right"> <button type="button" name="endereco" id="endereco" onclick="enderecos()" class="btn btn-info" > <i class="icon-plus"></i> Endereços </button> </td>';
							} else {
								echo '<td colspan=4> <input type="checkbox" name="cadastrarEndereco" id="cadastrarEndereco" value="1"> Na sequência deseja cadastrar o(s) endereço(s) do Advogado? </td>';
							}
						?>
						</tr>
					</table>
				</fieldset>
			</div>
			<?php
				echo '<table>';
					echo '<tr>';
						if(isset($_POST['id'])) {
							echo '<td> <button type="submit" name="atualizar" class="btn btn-success"> <i class="icon-refresh"></i> Atualizar </button>'; 
							echo '    <button type="button" name="cancelar" onclick="apagaForm()" class="btn btn-danger" > <i class="icon-ban-circle"></i> Cancelar </button>';
							echo '    <button type="button" name="voltar" id="voltar" onclick="loadPage(7);" class="btn btn-primary" > <i class="icon-arrow-left"></i> Voltar </button> <input type="hidden" id="controle" value="atualizar"> </td>';
						} else {
							echo '<td> <button type="submit" name="gravar" class="btn btn-success"> <i class="icon-ok"></i> Gravar </button>'; 
							echo '    <button type="button" name="cancelar" onclick="apagaForm()" class="btn btn-danger" > <i class="icon-ban-circle"></i> Cancelar </button>';
							echo '    <button type="button" name="sair" id="sair" onclick="loadPage(1);" class="btn btn-primary" > <i class="icon-home"></i> Sair </button> <input type="hidden" id="controle" value="gravar"> </td>';
						}
					echo '</tr>';
				echo '</table>';
			?>
		</form>
		<div id="retornoAdvogado"> </div>
		<div class="container">
				<h4>Favor preencha os campos abaixo citados:</h4>
				<ol>					
				</ol>
		</div>
	</body>
</html>